package com.hht.touchlibs

import android.content.Context
import android.view.View
import com.hht.touchlibs.ChildViewTouchEvent
import com.hht.touchlibs.LayoutViewTouchEvent
import com.hht.touchlibs.UserTouchEvent
import com.hht.touchlibs.UserTouchListener
import java.util.*


/**
 * Author:chen'hu
 * Time:2024/6/13 13:55
 * Description:This is UserTouchManager
 */
object UserTouchManager {
    private val mChildViewList = LinkedList<UserTouchListener>()
    private val mLayoutViewList = LinkedList<UserTouchListener>()

    //add child view
    fun addChileViewTouchEvent(mContext: Context, view: View, mTouchEvent: UserTouchEvent) {
        mChildViewList.add(ChildViewTouchEvent(mContext, view, mTouchEvent!!))
    }

    // add layout (LinearLayout ...)
    fun addLayoutViewTouchEvent(mContext: Context, view: View, mTouchEvent: UserTouchEvent) {
        mLayoutViewList.add(LayoutViewTouchEvent(mContext, view, mTouchEvent))
    }

    fun onRecoveryTouch() {
        for (touchListener in mChildViewList) {
            touchListener.onRecoveryTouch()
        }
        for (touchListener in mLayoutViewList) {
            touchListener.onRecoveryTouch()
        }
        mChildViewList.clear()
        mLayoutViewList.clear()
    }
}